<?php
	require_once('auth.php');
?>
<?php
//checking connection and connecting to a database
require_once('connection/config.php');
//Connect to mysql server
	$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	//Select database
	$db = mysql_select_db(DB_DATABASE);
	if(!$db) {
		die("Unable to select database");
	}
//retrive promotions from the specials table
$result=mysql_query("SELECT * FROM specials")
or die("There are no records to display ... \n" . mysql_error()); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Specials</title>
<link href="stylesheets/admin_styles.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="validation/admin.js">
</script>
</head>
<body>
<div id="page">
<div id="header">
<h1>Specials Management </h1>
<a href="index.php">Home</a> | <a href="accounts.php">Accounts Management</a> | <a href="orders.php">Orders Management</a> | <a href="reservations.php">Reservation Management</a> | <a href="specials.php">Specials Management</a> | <a href="allocation.php">Staff Allocation Management</a> | <a href="messages.php">Messages Management</a> | <a href="logout.php">Logout</a>
</div>
<div id="container">
<table width="700" align="center">
<CAPTION><h3>MANAGE PROMOTIONS</h3></CAPTION>
<form name="specialsForm" id="specialsForm" action="specials-exec.php?id=1" method="post" onsubmit="return specialsValidate(this)">
<tr>
	<th></th>
	<th>Price</th>
	<th>Start Date</th>
	<th>End Date</th>
</tr>
<tr>
	<td>Pepperoni Combo</td>
	<td><input type="text" name="price" /></td>
	<td><input type="date" name="startDate" /></td>
	<td><input type="date" name="endDate" /></td>
	<td><input type="submit" name="Submit" value="Update" /></td>
</tr>
</form>
<form name="specialsForm" id="specialsForm" action="specials-exec.php?id=2" method="post" onsubmit="return specialsValidate(this)">
<tr>
	<td>Super Cheese Combo</td>
	<td><input type="text" name="price" /></td>
	<td><input type="date" name="startDate" /></td>
	<td><input type="date" name="endDate" /></td>
	<td><input type="submit" name="Submit" value="Update" /></td>
</tr>
</form>
<form name="specialsForm" id="specialsForm" action="specials-exec.php?id=3" method="post" onsubmit="return specialsValidate(this)">
<tr>
	<td>Super Meat Combo</td>
	<td><input type="text" name="price" /></td>
	<td><input type="date" name="startDate" /></td>
	<td><input type="date" name="endDate" /></td>
	<td><input type="submit" name="Submit" value="Update" /></td>
</tr>
</form>
<form name="specialsForm" id="specialsForm" action="specials-exec.php?id=4" method="post" onsubmit="return specialsValidate(this)">
<tr>
	<td>Supreme Combo</td>
	<td><input type="text" name="price" /></td>
	<td><input type="date" name="startDate" /></td>
	<td><input type="date" name="endDate" /></td>
	<td><input type="submit" name="Submit" value="Update" /></td>
</tr>
</form>
<form name="specialsForm" id="specialsForm" action="specials-exec.php?id=5" method="post" onsubmit="return specialsValidate(this)">
<tr>
	<td>Super Veggie Combo</td>
	<td><input type="text" name="price" /></td>
	<td><input type="date" name="startDate" /></td>
	<td><input type="date" name="endDate" /></td>
	<td><input type="submit" name="Submit" value="Update" /></td>
</tr>
</form>
</table>
<hr>
<table width="700" align="center">
<CAPTION><h3>PROMOTIONS LIST</h3></CAPTION>
<tr>
<th>Promotion ID</th>
<th>Promotion Name</th>
<th>Price</th>
<th>Start Date</th>
<th>End Date</th>
</tr>

<?php
//loop through all table rows
while ($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['specials_id']."</td>";
echo "<td>" . $row['special_name']."</td>";
echo "<td>" . $row['price']."</td>";
echo "<td>" . $row['start_date']."</td>";
echo "<td>" . $row['end_date']."</td>";
echo "</tr>";
}
mysql_free_result($result);
mysql_close($link);
?>
</table>
<hr>
</div>
<div id="footer">
<div class="bottom_addr">&copy; 2012 Pizza-Inn. All Rights Reserved</div>
</div>
</div>
</body>
</html>